package com.example.demo.dao;

import com.example.demo.model.News;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by admin on 2017/10/8.
 */
@Mapper
public interface NewsDao {
    String TABLE_NAME="news";
    String INSERT_CON="title,link,image,like_count,comment_count,created_date,user_id";
    String SELECT_CON="id,title,link,image,like_count,comment_count,created_date,user_id";

    @Insert({"insert into",TABLE_NAME,"(",INSERT_CON,") values (#{title},#{link},#{image},#{likeCount},#{commentCount},#{createdDate},#{userId})"})
    int addNews(News news);

    @Select({"select",SELECT_CON,"from",TABLE_NAME,"limit #{offset},#{limit}"})
    List<News> selectOffset(@Param("offset") int offset,@Param("limit") int limit);
}
